package com.wy.ifly.mvp.p;

import android.util.Log;

import androidx.lifecycle.LifecycleOwner;

import com.wy.ifly.mvp.b.GoodBean;
import com.wy.ifly.mvp.m.GoodModel;
import com.wy.ifly.mvp.m.IGoodModel;
import com.wy.ifly.mvp.v.IBaseView;
import com.wy.ifly.mvp.v.IGoodView;

import java.util.List;

/**
 * Time:7/19/21
 * Author:ypf
 * Description:
 */
public class GoodPresenter<T extends IBaseView> extends BasePresenter<T> {

    private String TAG = "GoodPresenter";


    private GoodModel goodModel = new GoodModel();

    public void fetch() {

        goodModel.loadData(new IGoodModel.OnLoadListener() {

            @Override
            public void loadComplete(List<GoodBean> beans) {
                ((IGoodView) iGoodView.get()).showData(beans);
            }

            @Override
            public void loadFailure(String msg) {
                ((IGoodView) iGoodView.get()).showError(msg);
            }

        });

    }

    @Override
    void onCreate(LifecycleOwner owner) {
        super.onCreate(owner);
        Log.i(TAG, "onCreate");
    }

    @Override
    void onDestroy(LifecycleOwner owner) {
        super.onDestroy(owner);
        Log.i(TAG, "onDestroy");
    }

}